package com.atguigu.eduorder.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * @author He Wentao
 * @since 2022/10/2 19:38
 */

public class OrderNoUtil {


    /**
     *  获取订单号
     */
    public static String getOrderNo(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        String newDate = sdf.format(new Date());
        StringBuilder result = new StringBuilder();
        Random random = new Random();

        for (int i = 0; i < 3; i++) {
            result.append(random.nextInt(10));
        }

        return (newDate+result).intern();
    }
}
